﻿using System;

namespace Vessel_calculation.Classes
{
	/// <summary>
	/// Class calculate coefficients for the bow's and stern's parts.
	/// </summary>
	public class Bow_coeffitients
	{		
		public static void Calc_bow_coeffitients(double L, double dL, int waterlines, ref double[] xf, ref double[] xa, out double[] kb, out double[] ks)
		{
			kb = new double[waterlines];
			ks = new double[waterlines];
			
			double[] xbb = new double[waterlines];
			double[] xbs = new double[waterlines];
			
			for (int i=0; i < waterlines; i++)
			{
				xf[i] = L/2 + xf[i];
				xa[i] = L/2 - xa[i];	
				
				xbb[i] = Math.Floor( xf[i] / dL ) * dL;
				xbs[i] = Math.Floor( xa[i] / dL ) * dL;
				
				kb[i] = 0.5*((xf[i]-xbb[i])/dL+1);
				ks[i] = 0.5*((xa[i]-xbs[i])/dL+1);
			}
		}
	}
}
